# -*- encoding: utf-8 -*-
"""

PyCharm 12使用barh函数来绘制条形图
2024年 10月 27日 14:14
coded by wenyang
文件的主要内容


"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl


def main():
    mpl.rcParams["font.sans-serif"] = ["SimHei"]
    mpl.rcParams["axes.unicode_minus"] = False
    x = np.arange(1, 9)
    y = np.random.randint(1, 10, 8)
    # plt.ylim(1, 8)
    # plt.xlim(1, 10)
    plt.ylabel("种类")
    plt.xlabel("数量")
    plt.title("条形图进行数据的展示")
    plt.barh(x, y, color = "r", alpha = 0.5, align = "center", label = "条形图展示", tick_label = ["A", "B", "C", "D", "E", "F", "G", "H"], hatch = "x")
    plt.legend()
    plt.show()



if __name__ == "__main__":
    main()
